import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsDate, IsEnum, IsOptional, IsString } from 'class-validator';
import { PagingReqDto } from '../../../../common/dtos/paging.req.dto';
import { LogLevel } from '../../../constants/log.constant';
import { HttpMethod } from '../../../constants/user-activity-log.constant';

export class GetUserActivityLogAdminReqDto extends PagingReqDto {
  @ApiProperty({ description: '排序字段', enum: ['createdAt'] })
  @IsEnum(['createdAt'], { message: '排序字段格式不正确' })
  readonly order_by: string;

  @ApiProperty({ description: '开始时间' })
  @IsDate({ message: '开始时间格式不正确' })
  @Type(() => Date)
  readonly start: Date;

  @ApiProperty({ description: '结束时间' })
  @IsDate({ message: '结束时间格式不正确' })
  @Type(() => Date)
  readonly end: Date;

  @ApiProperty({ description: '日志级别', enum: LogLevel, required: false })
  @IsEnum(LogLevel, { message: '日志级别格式不正确' })
  @IsOptional()
  readonly level: LogLevel;

  @ApiProperty({ description: '关键字', required: false })
  @IsString({ message: '关键字格式不正确' })
  @IsOptional()
  readonly keyword: string;

  @ApiProperty({ enum: HttpMethod, description: '请求方法', required: false })
  @IsEnum(HttpMethod, { message: '请求方法格式不正确' })
  @IsOptional()
  readonly method: HttpMethod;

  @ApiProperty({ description: '请求url,支持模糊查询', required: false })
  @IsString({ message: '请求url格式不正确' })
  @IsOptional()
  readonly url: string;

  @ApiProperty({ description: '请求信息,支持模糊查询', required: false })
  @IsString({ message: '请求信息格式不正确' })
  @IsOptional()
  readonly request_message: string;
}
